package com.taptech.doufu.ui.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.taptech.doufu.R;
import com.taptech.doufu.bean.AlbumsBean;
import com.taptech.doufu.ui.viewholder.ImageSubjectViewHolder;

import java.util.List;

/**
 * Created by lsy on 2015/8/31.
 */
public class ImageSubjectAdapter extends RecyclerView.Adapter<ImageSubjectViewHolder> {

    private Context mContext;
    private List<AlbumsBean> mDataList;

    public ImageSubjectAdapter(Context context , List<AlbumsBean> dataList){
        this.mContext = context;
        this.mDataList = dataList;
    }


    @Override
    public ImageSubjectViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.subject_item_layout , parent , false);
        return new ImageSubjectViewHolder(mContext , view);
    }

    @Override
    public void onBindViewHolder(ImageSubjectViewHolder holder, int position) {
        if (mDataList != null){
           holder.setViewHolderData(mDataList.get(position) , mDataList.size() , position);
        }
    }

    @Override
    public int getItemViewType(int position)
    {
        return super.getItemViewType(position);
    }

    @Override
    public int getItemCount() {
        if (mDataList != null ){
            return mDataList.size();
        }
        return 0;
    }
}
